#include <iostream>
#include <fstream>

#include "sendable.h"
#include "play.h"
#include "send_xml_impl.h"
#include "interpreter_send.h"

#include "model/dom.h"
#include "model/parser.h"
#include "model/dom_policy.h"
#include "model/model_class.h"
#include "model/interpreter.h"

#include "core/null_deleter.h"

namespace model {
	typedef parser<dom_policy> dom_parser;
}

#include <boost/shared_ptr.hpp>

using namespace std;

int main(int argc, char *argv[])
{
	ifstream ifs("model/test.xml");
	string buff;
	string line;
	while(ifs.good()) {
		getline(ifs, line);
		buff += line;
	}
	cout << "File: " << endl << buff << endl << endl;
	model::dom_parser pars;
	if(!pars.parse(buff)) {
		cerr << "Error beim Parsen!!11" << endl;
		return 1;
	}

	boost::shared_ptr<model::dom> node(pars.get_node());
	cout << node->to_string() << endl;

	model::client clt(*node);
	clt.print();

	// Testing sendable...
	model::interpreter &inter = clt.get_interpreters().front();
	boost::shared_ptr<model::interpreter> tmp(&inter, core::null_deleter());
	boost::shared_ptr<network::send_impl> impl(
		new network::send_xml_impl());
	network::interpreter_send snd(impl, tmp);
	cout << snd.get_string();

	return 0;
}

